package demo.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.ui.ModelMap;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor;

@Component
public class WebRequestInterceptorDemo implements WebRequestInterceptor {

    private static final Logger logger = LoggerFactory.getLogger(WebRequestInterceptorDemo.class);

    @Override
    public void preHandle(WebRequest request) throws Exception {
        String contextPath = request.getContextPath();
        String sessionId = request.getSessionId();
        logger.info("sessionId:{},contextPath:{}", sessionId, contextPath);
    }

    @Override
    public void postHandle(WebRequest request, ModelMap model) throws Exception {

    }

    @Override
    public void afterCompletion(WebRequest request, Exception ex) throws Exception {

    }

}
